<%@ page import="java.sql.*" %>
<%--
  Created by IntelliJ IDEA.
  User: xujc
  Date: 7/6/15
  Time: 10:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>插入学生信息</title>
  <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
</head>
<br>
<h1>插入学生信息</h1>
<form action="/doinsert" method="post">
  姓名
  <input type="text" name="name"/>
  <br/>
  学号
  <input type="text" name="id"/>
  <br/>
  成绩
  <input type="text" name="grade"/>
  <br/>
  <input type="submit" value="提交"/>

</form>
<br/>
<form action="/doselect.jsp" method="post">
  学号
  <input type="text" name="id"/>
  <br/>
    <input type="submit" value="查询"/>

</form>
<br/>
<br/>
<div>
  <table>
    <tr>
      <th>
        学号
      </th>
      <th>
        姓名
      </th>
      <th>
        成绩
      </th>
    </tr>
  <%
    Connection con= DriverManager.getConnection("jdbc:mysql://localhost:3306/test");
    Statement statement = con.createStatement();
    ResultSet resultSet = statement.executeQuery("SELECT * FROM student");
    while (resultSet.next()){
      out.println("<tr>");
      out.print("<td>");
      out.print(resultSet.getString("sid"));
      out.println("</td>");
      out.print("<td>");
      out.print(resultSet.getString("name"));
      out.println("</td>");
      out.print("<td>");
      out.print(resultSet.getInt("grade"));
      out.println("</td>");
      out.println("</tr>");

    }
    con.close();
  %>
  </table>
</div>
</body>
</html>
